#pragma once

#include <QWidget>
#include <QDebug>
#include <QTimer>
#include <mutex>
#include <queue>

#include <pcl/point_types.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/visualization/range_image_visualizer.h>
#include <pcl/compression/octree_pointcloud_compression.h>

#include <opencv2/opencv.hpp>

#include "LidarDataManager.h"
#include "LidarConfigurationOptions.h"

using namespace pcl::visualization;

class DemoWidget : public QWidget
{
    Q_OBJECT
public:
    DemoWidget(QWidget *parent = nullptr);
    ~DemoWidget();

private:
    std::shared_ptr<PCLVisualizer> pcl_viewer;
    std::shared_ptr<pcl::PointCloud<pcl::PointXYZI>> cloud;
    QTimer *timer;
    std::queue<PointCloudData<pcl::PointXYZI>> cloud_queue;
    std::mutex mtx_viewer;

    ILidarDataManager *_dataManager = nullptr;

    bool processData(PointCloudData<pcl::PointXYZI> &data);

private slots:
    void updateViewer();
};